/***************************************************************************
 * CR_Slinks -- Copyright Bit Armory Labs 2007
 *
 * FILE:     Helper.cs, 10 code lines, [191 Bytes]
 * DATE:     8/25/2007 7:09 PM
 * MODIFIED: 8/25/2007 7:10 PM
 * PATH:     C:\Programming\Projects\Slinks\CR_Slinks
 *
 * NAMESPACE: CR_PageLinks
 * CLASS:     Helper
 *
 * AUTHOR:   Brian Chavez (Cowboy), bchavez@bitarmory.com
 *
 ***************************************************************************/


using System.Security.Cryptography;
namespace Slink.Core
{
    public static class Utils
    {
        public static string CalculateMD5( string unhashed )
        {
            byte[] data = new byte[unhashed.Length];
            data = System.Text.Encoding.ASCII.GetBytes( unhashed );

            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] result = md5.ComputeHash( data );

            System.Text.StringBuilder output = new System.Text.StringBuilder( result.Length );
            for( int i = 0; i < result.Length; i++ )
            {
                output.Append( result[i].ToString( "X2" ) );
            }

            return output.ToString().ToLower();
        }
    }
}